from annoying.functions import get_object_or_None
from core.forms import LoginForm
from core.models import User

def auth(request):
    context = {'user': None}
    user_id = request.session.get('user_id')
    if user_id is not None:
        context['user'] = get_object_or_None(User, id=user_id)
    if context['user'] is None:
        context['login_form'] = LoginForm()
    return context
